#include "HistorySession.h"
#include "../Impp.h"

namespace Impp
{


HistorySession::HistorySession(db_id id, const wxDateTime & sessionStart, const wxDateTime & sessionEnd) :
	id(id),sessionStart(sessionStart),sessionEnd(sessionEnd)
{

}

HistorySession::~HistorySession()
{
}

bool HistorySession::operator==(HistorySession& session){
	return this->id == session.id;
}

db_id HistorySession::getId(){
	return id;
}

void HistorySession::updateSessionEnd(const wxDateTime & sessionEnd){
	this->sessionEnd = sessionEnd;
}

wxTimeSpan HistorySession::getTimeSinceLastMessage(const wxDateTime & time){
	return time.Subtract(sessionEnd);
}

void HistorySession::getHistoryEntries(std::vector<HistoryEntry*> & out){
	Impp::exemplar()->getDatabase()->getHistoryEntries(out, this);
}

wxDateTime HistorySession::getSessionStart(){
	return sessionStart;
}

HistoryEntry* HistorySession::getLastEntry(){
	return Impp::exemplar()->getDatabase()->getLastHistoryEntry(this);
}


}
